/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System Driver Module                                  */
/*    Memory (ROM/RAM) access routines                                       */
/*                                                                           */
/*    Copyright (C) 2005 Laszlo Arvai                                        */
/*                                                                           */
/*****************************************************************************/

///////////////////////////////////////////////////////////////////////////////
// Include files
#include "drvMemoryAccess.h"

// buffer for the GUI objects
dosByte* const g_gui_buffer = ((dosByte*)(drvFRAME_BUFFER_ADDRESS + 9600));

// Memory for the frame buffer
dosByte* const g_frame_buffer = (dosByte*)(drvFRAME_BUFFER_ADDRESS);


///////////////////////////////////////////////////////////////////////////////
// Init memory access system 
void krnlInitMemoryAccess(void)
{
  MCUCR |= _BV(SRE);
  XMCRA = _BV(SRL2) | _BV(SRW01) | _BV(SRW00);
  XMCRB = 0;//_BV(XMBK);
	PORTG |= _BV(PG0) | _BV(PG1);
	RAMPZ = 1;

  drvMEM_BankDDR |= drvMEM_BankBitMask;
	krnlSelectRAMBank( drvMEM_BANK0 );
}

///////////////////////////////////////////////////////////////////////////////
// Select RAM Bank
void krnlSelectRAMBank( dosByte in_bank)
{
	PORTE = (PORTE & 0x03) | in_bank;
}
